package com.example.springaop.controller;

import com.example.springaop.model.UserInfo;
import com.example.springaop.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.beans.Transient;
import java.io.IOException;

@RestController
@RequestMapping("/user")
public class UserController {
//    @Autowired      //事务管理器
//    private DataSourceTransactionManager dataSourceTransactionManager;
//    @Autowired      //定义事务属性
//    private TransactionDefinition transactionDefinition;

    @Autowired
    private UserService userService;


    //@Transactional
    @RequestMapping("/u1")
    public Integer InsertUser(String userName ,String password){
        Integer result = userService.insert(userName, password);
        Integer result1 = userService.insertLog(userName,"op");
        return result;
    }

}
